//
//  BaseTableViewController.swift
//  JJWeibo
//
//  Created by JJ on 15/8/31.
//  Copyright © 2015年 JJ. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController {
    
    var visitorLoginView:VisitorLoginView?

    override func viewDidLoad() {
        super.viewDidLoad()
    
    }
    var userLogin=UserAccountViewModel.sharedUserAccount.userLogon
    
    override func loadView() {
        userLogin ? super.loadView() : setUpVistorView()
    }
    
    private func setUpVistorView(){
        
        visitorLoginView=VisitorLoginView()
        view=visitorLoginView
        
        self.navigationItem.leftBarButtonItem=UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: nil, action: nil)
        self.navigationItem.rightBarButtonItem=UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: nil, action: nil)
        
        visitorLoginView?.loginButton.addTarget(self, action: "VisitorLoginViewWillLogin", forControlEvents: UIControlEvents.TouchUpInside)
        visitorLoginView?.registButton.addTarget(self, action: "VisitorLoginViewWillRegist", forControlEvents: UIControlEvents.TouchUpInside)
        
    }
    
   @objc private func VisitorLoginViewWillLogin() {
    
        let nav=UINavigationController(rootViewController: OAuthVIewController())
        presentViewController(nav, animated: true, completion: nil)
    }
    
   @objc private func VisitorLoginViewWillRegist() {
    let nav=UINavigationController(rootViewController: OAuthVIewController())
    presentViewController(nav, animated: true, completion: nil)
    }


}
